package me.zhengjie.modules.quartz.task.retry;

import com.qiaofang.applet.service.property.domain.SyncDataErrorLog;
import com.qiaofang.applet.service.property.service.SyncDataLogService;
import lombok.extern.slf4j.Slf4j;
import me.zhengjie.modules.sync.DataErrorPullService;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class PullDataErrorRetryTask {
    @Autowired
    SyncDataLogService syncDataLogService;

    @Autowired
    DataErrorPullService dataErrorPullService;

    public void retry(){
        Page<SyncDataErrorLog> page=syncDataLogService.findByRetryIsTrue(1,20);
        while (page.getTotalElements()>0){
            page.forEach(item->{
                dataErrorPullService.pullSyncByDataErrorLog(item);
            });
            page=syncDataLogService.findByRetryIsTrue(1,20);
        }
    }
}
